#ifndef _DATABLOCK_H_
#define _DATABLOCK_H_

#include <windows.h>

static const unsigned int g_page_size = 4096;
static const unsigned int g_page_mask = 0xFFFFF000;

template <class OBJECT>
class DataBlock
{
private:
	ULONG_PTR _page_start;
public:
	DataBlock(unsigned int nb_objects):_page_start((ULONG_PTR)VirtualAlloc(NULL, nb_objects * sizeof(OBJECT), MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE)){}
	inline OBJECT & operator [] (unsigned int idx){return *(reinterpret_cast<OBJECT *>(_page_start + (idx * sizeof(OBJECT))));}
	inline const OBJECT & operator [] (unsigned int idx) const {return *(reinterpret_cast<const OBJECT *>(_page_start + (idx * sizeof(OBJECT))));}
};

#endif // _DATABLOCK_H_